package org.balabala.gateway.feign;

import org.balabala.gateway.config.MultiPartSupportConfiguration;
import org.balabala.gateway.entity.Video;
import org.balabala.gateway.response.Resp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@Component
@FeignClient(name = "video", configuration = MultiPartSupportConfiguration.class)

public interface VideoFeign {

    /**
     * 上传视频
     * @param file
     * @param video
     * @return
     */
    @PostMapping(value = "/balabala/video/put_video", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    Resp upload(@RequestBody MultipartFile file, @RequestParam("video") String video);


    /**
     * 获取视频详情
     * @param videoId
     * @return
     */
    @GetMapping(value = "/balabala/video/info/{videoId}")
    Resp getVideoInfo(@PathVariable("videoId") Long videoId);


    /**
     * 获取视频url
     * @param videoId
     * @return
     */
    @GetMapping(value = "/balabala/video/get_url/{videoId}")
    Resp getVideoURL(@PathVariable Long videoId);


    /**
     * 获取高热度视频
     * @param num
     * @return
     */
    @GetMapping(value = "/balabala/video/get_video/top/played")
    Resp getHotVideos(@RequestParam Integer num);


    /**
     * 同步视频播放次数
     * @param map
     * @return
     */
    @PostMapping(value = "/balabala/video/set_play_nums")
    Resp setVideoPlayNums(@RequestBody Map<Long,Integer> map);


    /**
     * 获取视频评论
     * @param videoId
     * @param limit
     * @param offset
     * @return
     */
    @GetMapping(value = "/balabala/video/get_video_comments")
    Resp getVideoComments(@RequestParam Long videoId,@RequestParam Integer limit,@RequestParam Integer offset);


    /**
     * 下架视频
     * @param videoIds
     * @return
     */
    @PostMapping(value = "/balabala/video/off_shelf")
    Resp offShelfVideo(@RequestBody Long[] videoIds);


    /**
     * 获取用户发布的视频
     * @param uid
     * @param limit
     * @param offset
     * @return
     */
    @PostMapping(value = "balabala/video/get_user_videos")
    Resp getUserVideos(@RequestParam Long uid,@RequestParam Integer limit,@RequestParam Integer offset);


    /**
     * 根据videoId获取视频抽帧图片url
     * @param videoId
     * @return
     */
    @GetMapping(value = "balabala/video/get_frame_url/{videoId}")
    Resp getFrameUrl(@PathVariable Long videoId);
}
